package com.tyc.kafka.listener;

import com.tyc.kafka.consumer.Consumer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;

/**
 * 类描述
 *
 * @author tyc
 * @version 1.0
 * @date 2022-10-19 13:56:05
 */
@Slf4j
public class ConsumerStart implements ApplicationListener<ContextRefreshedEvent> {
    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        new Thread(()->{
            Consumer consumer = (Consumer)contextRefreshedEvent.getApplicationContext().getBean("consumerTest");
            consumer.doConsume();
        }).start();
    }
}
